var alert_bar_hidden = false;

function start_loading() {
  hide_alert_bar();
  $(LOADING_ID).fadeIn();
}

function stop_loading() {
  $(LOADING_ID).fadeOut();
}

function stop_loading_msg(message) {
  stop_loading();
  alert_bar(message, 5);
}

function hide_alert_bar() {
  if(alert_bar_hidden) {
    $("#alert-bar").fadeOut('fast');
  }
}

function alert_bar(message, duration) {
  stop_loading(); /* Por si acaso */
  $('#alert-content').html(message);
  setTimeout(function(){$("#alert-bar").fadeIn(); alert_bar_hidden = true;}, 500);
  setTimeout(function(){$("#alert-bar").fadeOut(); alert_bar_hidden = false;}, duration * 1000 + 500);
}